package com.hs.srm.admin.modules.requisition.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.hs.srm.admin.modules.requisition.dao.ProPurchRequestItemSapDao;
import com.hs.srm.admin.modules.requisition.entity.ProPurchRequestItemEntity;
import com.hs.srm.admin.modules.requisition.service.ProPurchRequestItemSapService;
import org.springframework.stereotype.Service;

@Service("proPurchRequestItemSapService")
public class ProPurchRequestItemSapServiceImpl extends ServiceImpl<ProPurchRequestItemSapDao, ProPurchRequestItemEntity> implements ProPurchRequestItemSapService {
    @Override
    public boolean insertProItem(ProPurchRequestItemEntity ItemEntity) {
        boolean flg = this.insert(ItemEntity);
        return flg;
    }

    /**
     * 根据申请编码和行项目查找申请单
     *
     * @param bANFN
     * @param BNFPO
     * @return
     */
    @Override
    public ProPurchRequestItemEntity selectProItem(String bANFN, String BNFPO) {
        EntityWrapper<ProPurchRequestItemEntity> queryWrapper = new EntityWrapper<ProPurchRequestItemEntity>();
        queryWrapper.eq("purch_request_code", bANFN);
        queryWrapper.eq("purch_request_item_code", BNFPO);
        ProPurchRequestItemEntity one = this.selectOne(queryWrapper);
        if (one != null) {
            return one;
        }
        return null;
    }

    @Override
    public boolean updateProItem(ProPurchRequestItemEntity ItemEntity) {
        boolean flg = this.updateById(ItemEntity);
        return flg;
    }
}
